import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { SGuildLeaderImpeach } from "../../../../Message/Game/SGuildLeaderImpeach";
import { EGuildLeaderImpeachType } from "../../../../Message/Game/EGuildLeaderImpeachType";
import { DateParser } from "../../../common/tools/DateParser";
import { SPlayerGuildInfo } from "../../../../Message/Game/SPlayerGuildInfo";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Cache } from "../../cache/Cache";
import { EGuildPosition } from "../../../../Message/Game/EGuildPosition";
import { MsgManager } from "../../manager/MsgManager";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class GuildRefuteImpeachWindow
    
    export  class GuildRefuteImpeachWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(300, 200);
            this.titleHeight = 28;
            this.title = Language.getString(57405);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(17, 39, 265, 149, this);
            this._tipTxt = ObjCreate.createTextField("", 30, 50, 245, 97, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.multiline = true;
            this._tipTxt.wordWrap = true;
            this._impeachBtn = ObjCreate.createGButton(Language.getString(57408), 115, 155, 70, 28, this);
            this._impeachBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onImpeachBtnClickHandler);
            return;
        }

        public updateByGuildImpeach(arg1: SGuildLeaderImpeach): void
        {
            var loc1=null;
            if (arg1) 
            {
                if (arg1.impeachType != EGuildLeaderImpeachType._EGuildLeaderImpeachSystem) 
                {
                    this._tipTxt.htmlText = Language.getStringByParam(57428, arg1.leaderName, arg1.fromPlayer);
                }
                else 
                {
                    loc1 = DateParser.parse(arg1.endDate, Language.getString(57410));
                    this._tipTxt.htmlText = Language.getStringByParam(57409, arg1.leaderName, loc1, arg1.fromPlayer);
                }
            }
            return;
        }

        /* internal  */onImpeachBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            var e: Object /* flash.events.Event */;
            var myGuildInfo: SPlayerGuildInfo;
            var onBtnClickHandler: Function;

            var loc1;
            onBtnClickHandler = null;
            e = arg1;
            onBtnClickHandler = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuildRefuteImpeach));
                    Alert.resetToDefault();
                }
                return;
            }
            myGuildInfo = Cache.instance.guild.myGuildInfo;
            if (myGuildInfo && !(myGuildInfo.position == EGuildPosition._EGuildLeader)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(57411));
                return;
            }
            Alert.show(Language.getString(57426), null, Alert.OK | Alert.CANCEL, null, onBtnClickHandler);
            return;
        }

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_impeachBtn: GButton;
    }
